<?php

Raise::load('db.RaiseDbModel');

/**
 * RaiseDbModelBuilder class
 * Model builder based on table name and connection.
 *
 * @author Sam Yong
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package phpraise.db.core
 * @since 1.2
 */
class RaiseDbModelBuilder extends RaiseDbModel {
    
    function __construct($c, $table) {
        $this->table = $table;
        parent::__construct($c);
        $pk = new RaiseCollection();
        foreach($this->tableColumns() as $col){
            if($col->primaryKey()){
                $pk->add($col->name());
            }
        }
        if($pk->count() == 1){
            $this->primaryKey = $pk->get(0);
        }else{
            $this->primaryKey = $pk;
        }
    }

    
}
